import PromptBox from '@/components/PromptBox.vue'
import { createApp } from 'vue'

// let flag = true
function showPrompt(msg, type = 'normal') {
  // if (!flag) return
  // flag = false
  const propmtInstance = createApp(PromptBox)
  const container = document.createElement('div')
  document.body.appendChild(container)
  const prompt = propmtInstance.mount(container)
  if (type && typeof type !== 'string') {
    console.error('type不为string')
    return
  }

  prompt.show(msg, type)

  setTimeout(() => {
    container.remove()
    // flag = true
  }, 2500)
}

export default showPrompt
